package com.atguigu.service.impl;

import com.atguigu.entity.UserInfo;
import com.atguigu.mapper.UserInfoMapper;
import com.atguigu.service.UserInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author zhangqiang
 * @since 2021-09-03
 */
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {

    @Override
    public UserInfo queryUserFromdb(UserInfo uiUser) {
        QueryWrapper<UserInfo> userInfoQueryWrapper = new QueryWrapper<>();
        userInfoQueryWrapper.eq("login_name", uiUser.getLoginName());
        String loginName = uiUser.getLoginName();
        String bytes = uiUser.getPasswd();
        String encodePasswd = DigestUtils.md5DigestAsHex(bytes.getBytes());
        userInfoQueryWrapper.eq("passwd", encodePasswd);
        return baseMapper.selectOne(userInfoQueryWrapper);
    }
}
